package pt.nmfa.peste.session;

import pt.nmfa.peste.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("parametersList")
public class ParametersList extends EntityQuery<Parameters> {

	private static final String EJBQL = "select parameters from Parameters parameters";

	private static final String[] RESTRICTIONS = {
			"lower(parameters.fieldName) like lower(concat(#{parametersList.parameters.fieldName},'%'))",
			"lower(parameters.fieldValue) like lower(concat(#{parametersList.parameters.fieldValue},'%'))",
			"lower(parameters.fieldDescription) like lower(concat(#{parametersList.parameters.fieldDescription},'%'))", };

	private Parameters parameters = new Parameters();

	public ParametersList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Parameters getParameters() {
		return parameters;
	}
}
